package com.cyl.game.demos.web.controller;

import java.util.List;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cyl.game.demos.web.entity.UserSkinrelation;
import com.cyl.game.demos.web.service.UserSkinService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/user-skins")
@RequiredArgsConstructor
public class UserSkinController {

    private final UserSkinService userSkinService;

    // 添加用户拥有皮肤记录
    @PostMapping("/add")
    public String addUserSkin(@RequestBody UserSkinrelation userSkin) {
        userSkinService.addUserSkin(userSkin);
        return "用户拥有皮肤记录添加成功";
    }

    // 根据用户 ID 查询该用户拥有的所有皮肤
    @GetMapping("/{user_id}")
    public List<UserSkinrelation> getUserSkinsByUserId(@PathVariable("user_id") Integer user_id) {
        return userSkinService.getUserSkinsByUserId(user_id);
    }

    // 判断用户是否拥有特定皮肤
    @GetMapping("/check/{user_id}/{skin_id}")
    public boolean hasSkin(@PathVariable("user_id") Integer user_id, @PathVariable("skin_id") Integer skin_id) {
        return userSkinService.hasSkin(user_id, skin_id);
    }

    // 删除用户拥有的某条皮肤记录
    @DeleteMapping("/{user_id}/{skin_id}")
    public String deleteUserSkin(@PathVariable("user_id") Integer user_id, @PathVariable("skin_id") Integer skin_id) {
        userSkinService.deleteUserSkin(user_id, skin_id);
        return "用户拥有皮肤记录删除成功";
    }
}